package com.theone.dagger2.use3;

import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.theone.dagger2.App;
import com.theone.dagger2.bean.PersonBean;
import com.theone.dagger2.R;
import com.theone.dagger2.bean.UserBean;

import javax.inject.Inject;


/**
 * TODO 全局单例
 *
 * 生成代码位置：build/generated/ap_generated_sources/debug/out/com/theone/dagger2
 */
public class MainActivity3_2 extends AppCompatActivity {

    @Inject
    UserBean mUser;

    @Inject
    UserBean mUser2;

    @Inject
    PersonBean mPerson;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main1);

        // 全局单例
        ((App)getApplication()).getDataComponent3().injectMainActivity3_2(this);
        // DaggerDataComponent3.create().injectMainActivity3_2(this);

        TextView textView = findViewById(R.id.textview);
        textView.setText("User hashCode = "+mUser.hashCode()+" \n User2 hashCode = "+mUser2.hashCode()+"\n Person hashCode = "+mPerson.hashCode());

    }
}